package com.tanhua.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.mapper.QuestionMapper;
import com.tanhua.sso.pojo.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionServiceImpi implements QuestionService{

    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public Question findById(Long userId) {
        LambdaQueryWrapper<Question> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Question::getUserId,userId);
        Question question = questionMapper.selectOne(lambdaQueryWrapper);
        return question;
    }


    /*修改问题*/
    @Override
    public void update(Question question) {
        questionMapper.updateById(question);
    }

    /*保存问题*/
    @Override
    public void save(Question newQuestion) {
        questionMapper.insert(newQuestion);
    }
}
